Page({
  data: {
     autoplay: true,
    interval: 2000,
    duration: 500,
    circular: true,
    imgUrls: [
      "/images/shouye_04.png",
      "/images/shouye_05.png",
      "/images/shouye_06.png"
    ],
    order_goods_list:[]
  },
  onLoad(query) {
    console.log(query);
    this.init(query.order_id);
    this.add();
  },

  goDiscountTap(e){
    console.log(e);
    var id = e.currentTarget.dataset.id
    my.navigateTo({
      url: `/pages/main/discount/discount?order_goods_id=${id}`, // 需要跳转的 tabBar 页面的路径（需在 app.json 的 tabBar 字段定义的页面），路径后不能带参数
    });
  },

   add(){
        var img = this.imgUrls;
        var app = getApp()
        
      console.log(app.globadData.access_token);   
        var url = app.globadData.apiUrlHeader+'get-ads';
        // var a_token = app.globadData.access_token;
        my.httpRequest({
      url: url, // 目标服务器 url
      method:'Post',
      headers:{'Content-Type':'Application/json'},
      data:JSON.stringify({
         "access_token":app.globadData.access_token,
          "mini_program_id":"1",
          "ad_category_id":"1"
        }),
        dataType:'json',
        success: (res) => {
          console.log(res);
        if(res.data.status==0)
        {
          console.log(res.data.data);
           img = res.data.data;
          // console.log(img);
          this.setData({
           imgUrls : img
          });
        }
      },
      fail:(res)=>{
        console.log('in fail');
        console.log(res);
      },
    });
  },

  init(order_id){
      var app = getApp()
            var url = app.globadData.apiUrlHeader+'get-order-goods';
            var id = order_id;
            // id = '01fbe191-212f-11e8-aacd-6c0b8481e2be';
               my.httpRequest({
                   url: url, // 目标服务器 url
                   method:'Post',
                   headers:{'Content-Type':'Application/json'},
                   data:JSON.stringify({
                      "order_id":id,
                      "access_token":app.globadData.access_token
                    }),
                  dataType:'json',
                  success: (res) => {

                   console.log(res);
                  //  var jj = {"curHdIndex":0};
                    if(res.data.status == 0){
                      this.setData({
                        order_goods_list : res.data.data                      
                      });
                    }
                    
                   },
               });
  },
});
